//
//  ColorView.m
//  NanNote
//
//  Created by 郑楠 on 15/5/20.
//  Copyright (c) 2015年 ___NANteam___. All rights reserved.
//

#import "ColorView.h"

@implementation ColorView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        UIView *bgView = [[UIView alloc] initWithFrame:self.frame];
        [self addSubview:bgView];
        bgView.alpha = 0.7;
        
        UIButton *whiteBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        whiteBtn.frame = CGRectMake(20, 20, 60, 60);
        [whiteBtn setBackgroundColor:[UIColor whiteColor]];
        [whiteBtn.layer setBorderWidth: 1];
        [whiteBtn.layer setCornerRadius:30];
        [whiteBtn setTag:10000];
        [whiteBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:whiteBtn];
        
        UIButton *yellowBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        yellowBtn.frame = CGRectMake(100, 20, 60, 60);
        [yellowBtn setBackgroundColor:[UIColor yellowColor]];
        [yellowBtn.layer setBorderWidth: 1];
        [yellowBtn.layer setCornerRadius:30];
        [yellowBtn setTag:10001];
        [yellowBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:yellowBtn];
        
        UIButton *orangeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        orangeBtn.frame = CGRectMake(180, 20, 60, 60);
        [orangeBtn setBackgroundColor:[UIColor orangeColor]];
        [orangeBtn.layer setBorderWidth: 1];
        [orangeBtn.layer setCornerRadius:30];
        [orangeBtn setTag:10002];
        [orangeBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:orangeBtn];
        
        UIButton *cyanBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        cyanBtn.frame = CGRectMake(20, 100, 60, 60);
        [cyanBtn setBackgroundColor:[UIColor cyanColor]];
        [cyanBtn.layer setBorderWidth: 1];
        [cyanBtn.layer setCornerRadius:30];
        [cyanBtn setTag:10003];
        [cyanBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:cyanBtn];
        
        UIButton *grayBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        grayBtn.frame = CGRectMake(100, 100, 60, 60);
        [grayBtn setBackgroundColor:[UIColor grayColor]];
        [grayBtn.layer setBorderWidth: 1];
        [grayBtn.layer setCornerRadius:30];
        [grayBtn setTag:10004];
        [grayBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:grayBtn];
        
        UIButton *greenBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        greenBtn.frame = CGRectMake(180, 100, 60, 60);
        [greenBtn setBackgroundColor:[UIColor greenColor]];
        [greenBtn.layer setBorderWidth: 1];
        [greenBtn.layer setCornerRadius:30];
        [greenBtn setTag:10005];
        [greenBtn addTarget:self action:@selector(colorBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:greenBtn];
        
    }
    return self;
}

- (void)colorBtnClicked:(UIButton *)btn {
//    self.tagOfColorBlock(btn.tag);
    [self.delegate tagOfColor:btn.tag];
}

@end

//myWhiteColor,
//myYellowColor,
//myOrangeColor,
//myCyanColor,
//myGrayColor,
//myGreenColor